clear
set more off

use "$statadir/refund_share", clear

tostring amendment refund f7200 dep, format(%6.3f) replace force
tempfile touse
qui save `touse', replace

local stramendment "Form 941-X amendment" 
local strrefund "Form 941 refund"
local strf7200 "Form 7200 advance"
local strdep "Reduced deposits"


cap file close myfile
file open myfile using "$outdir/tables/refund_share.tex", write replace

file write myfile " & \multicolumn{2}{c}{Credit attributable to wages paid in...} \\ "
file write myfile " \cmidrule(lr){2-3} "
file write myfile " & 2020Q2-2020Q4 & 2021Q1-2021Q4 \\ "
file write myfile " & (1) & (2) \\ "
file write myfile " \hline "

foreach var in amendment refund f7200 dep {

	file write myfile "`str`var''"
	
	forval post = 0/1 {
		use `touse' if post == `post', clear
		local entry = `var'[1]
		
		file write myfile " & `entry ' "
	}
	file write myfile " \\ "
	if "`var'"~="dep" {
		file write myfile " \addlinespace[4pt] "
	}


}

file close myfile




/*
graph bar dep f7200 refund amendment, over(ctype) stack scheme(s1color) ///
	legend(order(1 "Reduced deposits" 2 "Form 7200 advance" 3 "Form 941 refund" 4 "941-X")) ///
	bar(1, fcolor(gs13) lcolor(black)) ///
        bar(2, fcolor(gs9) lcolor(black)) ///
        bar(3, fcolor(gs5) lcolor(black)) ///
        bar(4, fcolor(gs0) lcolor(black))
		
graph export "$outdir/figures/refund_share.eps", replace
*/
list
